﻿/////////////////////////////////////////////////////////
//该文件存放的类都是是为了统一管理某种类型的变量，
//如统一分配和管理配置文件的类
/////////////////////////////////////////////////////////

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CommonLib
{
    /// <summary>
    /// 统一分配和管理配置文件的类
    /// </summary>
    public class ConfigsAllocator
    {
        public static string appStartPath = Application.StartupPath.Remove(Application.StartupPath.LastIndexOf("\\bin"))+"\\";
        public static XMLConfig MainConfig
        { get { return getReadConfig("MainConfig.xml"); } }

        public static XMLConfig Preview
        { get { return getReadConfig("Preview.xml"); } }

        public static XMLConfig Statistic
        { get { return getReadConfig("CGGL\\Statistic.xml"); } }

        public static XMLConfig CompareDataPath
        { get { return getReadConfig("CGGL\\CompareDataPath.xml"); } }

        public static XMLConfig CustomConfig
        { get { return getReadConfig("CustomConfig.xml"); } }

        public static XMLConfig LoginConfig
        { get { return getReadConfig("CGGL\\LoginConfig.xml"); } }

        public static XMLConfig DataFolderConfig
        { get { return getReadConfig("DataFolderConfig.xml"); } }

        public static XMLConfig ResultDisplay
        { get { return getReadConfig("CGGL\\ResultDisplay.xml"); } }

        public static XMLConfig MonitorDataInput
        { get { return getReadConfig("Monitor\\MonitorDataInput.xml"); } }

        public static XMLConfig MonitorDataImportConfig
        { get { return getReadConfig("Monitor\\MonitorDataImportConfig.xml"); } }

        public static XMLConfig DataPreHandleConfig
        { get { return getReadConfig("SpatialData\\DataPreHandleConfig.xml"); } }

        public static XMLConfig ThematicMapConfig
        { get { return getReadConfig("Evaluation\\ThematicMapConfig.xml"); } }

        public static XMLConfig ChangerEvaluationConfig
        { get { return getReadConfig("Evaluation\\ChangerEvaluationConfig.xml"); } }
        public static XMLConfig ReportCreateConfig
        { get { return getReadConfig("ResultManage\\ReportCreateConfig.xml"); } }
        public static XMLConfig EvaluationStatisticsConfig
        { get { return getReadConfig("Evaluation\\EvaluationStatisticsConfig.xml"); } }
        public static XMLConfig PhotoManageConfig
        { get { return getReadConfig("ResultManage\\PhotoManageConfig.xml"); } }
        public static XMLConfig DataBaseFieldConfig
        { get { return getReadConfig("GradeResultGeneration\\DataBaseFieldConfig.xml"); } }
        public static XMLConfig TextManageConfig
        { get { return getReadConfig("ResultManage\\TextManageConfig.xml"); } }
        /// <summary>
        /// 对应的文件名获取对应的ReadConfig
        /// </summary>
        /// <param name="subFile">e.g. "PreView.xml"</param>
        /// <returns></returns>
        private static XMLConfig getReadConfig(string subFile)
        {
            return new XMLConfig(appStartPath + @"\Configs\" + subFile, true);
            //return new ReadConfig(FoldersAllocator.ConfigsFolder + "\\" + subFile);
        }
    }
    /// <summary>
    /// 统一分配和管理配置子文件夹的类
    /// </summary>
    public class FoldersAllocator
    {
        public static readonly string RootFolder = Application.StartupPath.Substring(0, Application.StartupPath.LastIndexOf("\\bin"))+"\\";

        public static readonly string SystemMxd = RootFolder+ "MapData";

        public static readonly string RegionResultFolder_JCPJ = RootFolder + "成果数据\\JCPJ\\县级成果";
        public static readonly string RegionResultFolder_BCWS = RootFolder + "成果数据\\BCWS\\县级成果";
        public static readonly string RegionResultFolder_NDBG = RootFolder + "成果数据\\NDBG\\县级成果";

        public static readonly string SystemMxdForResultManager = RootFolder + "MapData\\系统导航地图.mxd";

        public static readonly string safeDataBase = RootFolder + "Data\\UserData.safe.dat";

        public static readonly string DataFolder = RootFolder + "Data";

        public static readonly string ConfigsFolder = RootFolder + "Configs";

        /// <summary>放结果的文件夹 </summary>
        public static readonly string resultFolder=RootFolder+ "县级成果";
        /// <summary>customFolder文件夹的路径 </summary> 
        public static readonly string customFolder=RootFolder+ "CustomFolder";

        public static readonly string ResultsFolder = getResultsFolder();//IP+文件夹

        public static string getResultFolder()
        {
            XMLConfig m_cfo = new XMLConfig("CGGL\\LoginConfig.xml");
            string resultFolder = m_cfo.GetAttributeValueFromSpcialAttribute("Login", "type", "Server", "value");
            return resultFolder;
        }

        public static string getResultsFolder()
        {
            string path = "";
            path = @"\\" + getResultFolder();
            return path;
        }
    }
}
